package spring.core.aop.pointcut;

import spring.core.aop.DefaultTeacherService;
import spring.core.aop.TeacherMethodInterceptor;
import spring.core.aop.TeacherService;

import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;

/**
 * @author 1203056
 * @version Id: PointcutAPIDemo.java, v 0.1 2021-09-07 0:03 1203056 Exp $
 */
public class PointcutAPIDemo {
    public static void main(String[] args) {
        DefaultTeacherService target = new DefaultTeacherService();
        ProxyFactory proxyFactory = new ProxyFactory(target);
        proxyFactory.addAdvisor(new DefaultPointcutAdvisor(new TeacherServicePointcut("teach", TeacherService.class),new TeacherMethodInterceptor()));
        TeacherService proxy = (TeacherService)proxyFactory.getProxy();
        proxy.teach("语文");

    }
}
